package cn.tedu.net.collection.api;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;

//本类用于复习string类
public class Test0_StringDome {
    public static void main(String[] args) {
    //创建String对象的两种方式  直接写和new
    char[] value={'a','b','c'};
    String s=new String(value);
    String s1="abc";
    //测试常用方法
        System.out.println(s1.charAt(2));
        System.out.println(s1.concat("cxy"));
        System.out.println(s1.endsWith("xy"));
        System.out.println(s1.endsWith("bc"));
        String s2=s1.concat("cxy");
        System.out.println(s2.endsWith("xy"));
        System.out.println(s.equals(s1));
        System.out.println(s.codePointAt(0));
        System.out.println(s.codePointBefore(1));
        System.out.println(s.codePointCount(0,2));
        byte[] b =s1.getBytes(StandardCharsets.UTF_8);
        System.out.println(Arrays.toString(b));
        System.out.println(s.compareTo("abcdefg"));
        System.out.println(s1.indexOf("c"));
        System.out.println(s1.lastIndexOf("c"));
        System.out.println(s1.length());
        s2="      abc    ";
        System.out.println(s2.trim());
        s2="abcdefg";
        System.out.println(s2.substring(3));
        System.out.println(s2.substring(2,5));
        System.out.println(String.valueOf(20));
    }
}
